/*
 * @LastEditors: c
* @Description: 
 * @FilePath: \music-web-backend\src\core\music\video\dto\create-video.dto.ts
* https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { Transform } from "class-transformer";
import { IsArray, IsDate, IsEnum, IsNumber, IsOptional, IsString, IsUrl, MaxLength } from "class-validator";
import { LangEnum } from "src/common/enums";
import { ResolutionEnum } from "src/common/enums/video.enum";

export class ResolutionType {
    resolution: ResolutionEnum
    path: string
}

export class VideoForm {

    //视频id
    @IsOptional()
    // @IsUUID("all", { message: "视频id格式不正确" })
    id?: string;

    url?: string;
    /**
     * 歌手ID列表
     */
    @IsOptional()
    @IsArray({ message: "歌手id格式不是数组格式" })
    @IsNumber({ allowNaN: false }, { message: "歌手id格式不正确", each: true })
    artistIds: number[];

    //视频、图片高度
    @IsOptional()
    @IsNumber({ allowNaN: false }, { message: "视频高度格式不正确" })
    height?: number;
    //视频、图片宽度
    @IsOptional()
    @IsNumber({ allowNaN: false }, { message: "视频宽度格式不正确" })
    width?: number;
    //视频时长
    @IsOptional()
    @IsNumber({ allowNaN: false }, { message: "视频长度格式不正确" })
    duration?: number;

    //存储名称
    @IsOptional()
    @IsString({ message: "存储文件名称格式不正确" })
    objectName?: string;

    //唯一Code
    @IsOptional()
    assetCode?: string;

    //简介
    @IsOptional()
    @IsString({ message: "简介格式不对" })
    @MaxLength(500, { message: "简介文本长度不能超过500" })
    introduce: string;

    //语言缩写(zh)
    @IsOptional()
    @IsEnum(LangEnum, { message: "语言格式不正确" })
    lang: LangEnum;

    //标签 id或者文本
    @IsOptional()
    genre?: number | string;

    //封面图
    @IsUrl({ host_whitelist: ['localhost'] }, { message: "视频封面图链接格式不对", each: true })
    poster: string;

    //发行时间
    @IsOptional()
    @Transform(v => new Date(v))
    @IsDate({ message: "日期格式不正确" })
    originalReleaseDate: Date;

    //mv标题
    @IsOptional()
    @IsString({ message: "标题格式不正确" })
    @MaxLength(200, { message: "标题长度不正确" })
    title: string;

    //新增时间?
    @IsOptional()
    @Transform(v => new Date(v))
    @IsDate({ message: "日期格式不正确" })
    indexDataAddTime: Date;

    //播放总次数
    @IsOptional()
    @IsNumber({ allowNaN: false }, { message: "播放次数格式不正确" })
    playnum: number;

    allRate?: ResolutionType[]
    //分辨率
    resolution?: ResolutionEnum[]
    //歌曲的id
    @IsOptional()
    @IsArray()
    @IsString({ each: true })
    trackId?: string[]

    trackAssetCode?: string[]
    songOptions: { label: string; value: number; }[];
    
    @IsOptional()
    @IsArray()
    @IsNumber({ allowNaN: false }, { each: true })
    songIds: number[];

}


